![]() |
Java Database Programming with JDBC
by Pratik Patel Coriolis, The Coriolis Group ISBN: 1576100561 Pub Date: 10/01/96 |
Previous | Table of Contents | Next |
This class is used to map the SQL data type TIMESTAMP. It extends java.util.Date, and has nanosecond precision for time-stamping purposes.
Constructors
Constructor | Additional Description |
---|---|
public Timestamp(int year, int month, int date, int hour, int minute, int second, int nano) | Builds a Timestamp object using the int parameters: year, month, date, hour, minute, second, and nano |
Methods
Method Name | Additional Description |
---|---|
public boolean equals(Timestamp tstamp) | Compares the Timestamp object with the Timestamp parameter tstamp; returns true if they match |
public int getNanos() | Returns the Timestamp objects nanoseconds |
public void setNanos(int n) | Sets the Timestamp objects nanosecond value |
public String toString() | Returns a formatted String object with the value of the Timestamp object in the format: YYYY-MM-DD HH:MM:SS.F |
public static Timestamp valueOf(String strts) | Returns a Timestamp object converted from the strts parameter that is in the previous format |
This class contains the SQL data types as constants. It is used by other classes as the standard constant for the data types.
Constructors
Constructor | Additional Description |
---|---|
public Types() | Builds a Types object; not usually necessary as they can be accessed as so: Types.BIGINT |
Variables
Next are the interface listings. As with the class listings, each interface listing includes a description and the interfaces methods and variables.
This is the primary interface to access stored procedures on a database. If OUT parameters are specified and a query is executed via this class, its results are fetched from this class and not the ResultSet class. This class extends the PreparedStatement class, thus inheriting many of its methods.
The first 15 methods (the get methods) are identical in functionality to those in the ResultSet class, but they are necessary if OUT parameters are used. See the ResultSet class for a description of the methods.
Methods
Method Name | Additional Description |
---|---|
public abstract boolean getBoolean(int parameterIndex) throws SQLException | |
public abstract byte getByte(int parameterIndex) throws SQLException | |
public abstract byte[] getBytes(int parameterIndex) throws SQLException | |
public abstract Date getDate(int parameterIndex) throws SQLException | |
public abstract double getDouble(int parameterIndex) throws SQLException | |
public abstract float getFloat(int parameterIndex) throws SQLException | |
public abstract int getInt(int parameterIndex) throws SQLException | |
public abstract long getLong(int parameterIndex) throws SQLException | |
public abstract Numeric getNumeric(int parameterIndex, int scale) throws SQLException | |
public abstract Object getObject(int parameterIndex) throws SQLException | |
public abstract short getShort(int parameterIndex) throws SQLException | |
public abstract String getString(int parameterIndex) throws SQLException | |
public abstract Time getTime(int parameterIndex) throws SQLException | |
public abstract Timestamp getTimestamp(int parameterIndex) throws SQLException | |
public abstract void registerOutParameter(int paramIndex, int sqlDataType) throws SQLException | Each parameter of the stored procedure must be registered before the query is run; paramIndex is the stored procs parameter location in the output sequence, and sqlDataType is the data type of the parameter at the specified location (sqlDataType should be set from the Type class using one of its variables, for example, Types.BIGINT) |
public abstract void registerOutParameter(int parameterIndex, int sqlDataType, int scale) throws SQLException | Specifies the number of places to the right of the decimal desired when getting Numeric data objects |
public abstract boolean wasNull() throws SQLException | Returns true if the stored proc parameter was value NULL |
This is the high-level class used to interact with a database. The object is established from the DriverManager.getConnection method, which returns this object (Connection). This class obtains information about the specific database connection via the instantiated JDBC driver, and its primary use is to perform queries via the createStatement, prepareCall, and prepareStatement methods, which return Statement, PreparedCall, and PreparedStatement objects, respectively.
Previous | Table of Contents | Next |